package pl.oczadly.jabberclient.connection;

import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;

import pl.oczadly.jabberclient.utils.Utils;

public class ConnectionHolder {

	private static ConnectionHolder connectionHolder;
	
	private static ConnectionConfiguration config = new ConnectionConfiguration( Utils.SERVER );
	
	private static XMPPConnection connection = new XMPPConnection( config );
	
	private ConnectionHolder() {}
	
	public static ConnectionHolder getInstance() {
		if( connectionHolder == null )
			connectionHolder = new ConnectionHolder();
		
		return connectionHolder;
	}
	
	public static ConnectionConfiguration getConfig() {
		return config;
	}
	
	public static XMPPConnection getConnection() {
		return connection;
	}
	
	public static void createEntry( String id, String name, String[] arg ) throws XMPPException {
		Roster roster = connection.getRoster();
		roster.createEntry( id, name, arg );
	}
	
	public static Roster getRoster() {
		return connection.getRoster();
	}
	
}
